class Background
  attr_reader :y
  #animation = the picture file
  #x = x coordinate
  #y = y coordinate
  #speed = scroll speed (downwards, y increases as you go down)
  #scale_x and scale_y are values if you want increase the size or decrease the size of the image
  #order is the ZModule order... ie where on the Z axis this background should be; neeeded for parallax scrolling
  def initialize(animation, x, y, speed, scale_x, scale_y, order)
    @x = x
    @y = y
    @speed = speed
    @img = animation
    @scale_x = scale_x
    @scale_y = scale_y
    @order = order
    @vel_y = 0
  end
  
  #Draw Background
  def draw
    @img.draw(@x - @img.width / 2.0, @y - @img.height / 2.0, @order, @scale_x, @scale_y)
  end
  
  #Accelerate the background with a constant acceleration. Remove from screen if exited.
  def accelerate(acceleration)
    @acceleration = acceleration
    @vel_y += @acceleration
    @y += @vel_y
    (@y - @img.height / 2.0) < 480.0
  end
  
  #update increases the y position by speed every cycle, and checks to see if it has left the screen
  #update will return false (i believe) if the image has left the screen
  def update
    @y += @speed
    (@y - @img.height / 2.0) < 480.0
  end
end